<?php
class DirectoryComponent extends Object {
	
	public function __construct() {
		parent::__construct ();
	}
	

	public function directory_map($source_dir, $top_level_only = FALSE)
	{	
		if ($fp = @opendir($source_dir))
		{
			$source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
			$filedata = array();

			while (FALSE !== ($file = readdir($fp)))
			{
				if (strncmp($file, '.', 1) == 0)
					continue;

				if ($top_level_only == FALSE && @is_dir($source_dir.$file))
				{
					$temp_array = array();

					$temp_array = $this->directory_map($source_dir.$file.DIRECTORY_SEPARATOR);

					$filedata[$file] = $temp_array;
				}
				else
					$filedata[] = $file;
			}
			closedir($fp);
			return $filedata;
		}
	}

	
	public function directory_unlink($source_file){
		return unlink($source_file);
	}

	public function directory_rmdir($source_dir){
		return rmdir($source_dir);
	}
}

?>